package cn.huiyunche.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.huiyunche.base.service.interfaces.impl.BannerServiceImpl;
import cn.huiyunche.base.service.model.SysAdminBanner;
import cn.huiyunche.base.service.vo.Result;

/**
 * banner
 * @author hdy [Tuffy]
 *
 */
@Controller
@RequestMapping("/banner")
public class BannerController {
	
	@Autowired
	private BannerServiceImpl bannerServiceImpl = null;
	
	
	@RequestMapping(method= RequestMethod.GET)
	@ResponseBody
	public Result<List<SysAdminBanner>> myBanner(Long bannerId) {
		return this.getBannerServiceImpl().myBanner(bannerId);
	}
	
	@RequestMapping(value = "/{id}", method= RequestMethod.GET)
	@ResponseBody
	public Result<SysAdminBanner> myBannerById(@PathVariable Long id) {
		return this.getBannerServiceImpl().myBannerById(id);
	}
	
	@RequestMapping(value = "/edit", method= RequestMethod.POST)
	@ResponseBody
	public Result<String> saveMyBanner(SysAdminBanner sab) {
		return this.getBannerServiceImpl().saveMyBanner(sab);
	}
	
	@RequestMapping(value = "/all", method= RequestMethod.GET)
	@ResponseBody
	public Result<List<SysAdminBanner>> allBanner() {
		return this.getBannerServiceImpl().allBanner();
	}
	
	private BannerServiceImpl getBannerServiceImpl() {
		return this.bannerServiceImpl;
	}
}
